def download(loc, path):
	import tarfile
	import zipfile
	import urllib
	import os
	
	#get the filename from the url
	name=loc[(loc.rfind('/')):]
	
	source="%s/%s" % (path, name)
	
	urllib.urlretrieve(loc, source)
	
	if zipfile.is_zipfile(source):
		zip=zipfile.ZipFile(source)
		
		for name in zip.namelist():
			fullpath=os.path.join(path, name)
			if name.endswith('/'):
				os.mkdir(fullpath)
			else:
				outfile = open(fullpath, 'wb')
				outfile.write(zip.read(name))
				outfile.close()
		
	elif tarfile.is_tarfile(source):
		tar=tarfile.open(source)
		
		tar.extractall(path)
	
	
